﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QRCode.BusinessEntities;

namespace QRCode.BusinessLayer
{
    public class CodeManager:BaseManager<Code>
    {
        public IQueryable<Code> FindList(int uId)
        {
            return base.Repository.FindList(a => a.UserID == uId);
        }
        public IQueryable<Code> FindList(List<int> cIds)
        {
            return base.Repository.FindList(a=>cIds.Contains(a.CodeId));
        }
        public IQueryable<Code> FindList(int uId, DateTime start, DateTime end, int sIndex)
        {
            if (sIndex == 1)
            {
                return base.Repository.FindList(a => a.UserID == uId && a.CreatTime >= start && a.CreatTime <= end && a.ExportTime == null);
            }
            else if (sIndex == 2)
            {
                return base.Repository.FindList(a => a.UserID == uId && a.CreatTime >= start && a.CreatTime <= end && a.ExportTime != null);
            }
            else
            {
                return base.Repository.FindList(a => a.UserID == uId && a.CreatTime >= start && a.CreatTime <= end);
            }
        }
    }
}
